{%extends "base.html"%}

{%block mainmenu%}
  <a href="{%url codereview.views.index%}" class="active">Issues</a>
  <a href="{%url codereview.views.search%}">Search</a>
{%endblock%}


{%block mainmenu2%}
  {%if user%}
    {%comment%}
    <a href="{%url codereview.views.use_uploadpy%}">Create Issue</a>
    {%endcomment%}
    &nbsp;&nbsp;&nbsp;
    <a href="{%url codereview.views.mine%}">My Issues</a>
    |
    <a href="{%url codereview.views.starred%}">Starred</a>
    &nbsp;&nbsp;&nbsp;
    <a href="{%url codereview.views.view_all%}?closed=0">Open</a>
    |
    <a href="{%url codereview.views.view_all%}?closed=1">Closed</a>
    |
    <a href="{%url codereview.views.view_all%}">All</a>
  {%else%}
    <a class="novisit" href="{%url codereview.views.index%}?closed=0">Open Issues</a>
    |
    <a class="novisit" href="{%url codereview.views.index%}?closed=1">Closed Issues</a>
    |
    <a class="novisit" href="{%url codereview.views.view_all%}">All Issues</a>
    |
    <a class="novisit" href="{{sign_in}}">Sign in</a>
    with your <a href="https://www.google.com/accounts/NewAccount">Google
    Account</a> to create issues and add comments
  {%endif%}
{%endblock%}


{%block body%}
  <h2>
    {%include "issue_star.html"%}
{%if issue.edit_allowed and not issue.closed%}
<span class="issue-close" id="issue-close-{{issue.key.id}}">
    <a href="javascript:M_closeIssue({{issue.key.id}})">
      <img src="{{media_url}}close.gif" title="Close This Issue" width="15"
	   height="15" border="0"></a>
</span>
{%endif%}
    Issue <a href="{%url codereview.views.show issue.key.id%}"
               onmouseover="M_showPopUp(this, 'popup-issue');">
            {{issue.key.id}}</a>:
    {{issue.subject}} {%if issue.closed %} (Closed) {%endif%}
  </h2>

  <table class="issue-details" border="0" width="100%">
    <tr valign="top">

      <td class="meta" width="20%">
        {%block issue_actions%}
          <div>
            {%if issue.edit_allowed%}
              <a class="novisit"
                 href="{%url codereview.views.edit issue.key.id%}">
                Edit Issue
              </a>
            {%else%}
              <span class="disabled">Can't Edit</span>
            {%endif%}
            <br/>
            {%if user%}
              <a class="novisit"
                 href="{%url codereview.views.publish issue.key.id%}">
                Publish+Mail Comments
              </a> ('m')
            {%else%}
              <span class="disabled">Can't Publish+Mail</span>
            {%endif%}
            {%if last_patchset and first_patch%}
              <br/>
              <a class="novisit"
                 href="{%url codereview.views.diff issue.key.id,last_patchset.key.id,first_patch.filename%}">
                <b>Start Review</b>
              </a>
            {%endif%}
          </div>
        {%endblock%}
        <div class="issue_details_sidebar">
          <div><b>Created:</b><br/>
            {{issue.created|timesince}} ago by {{issue.owner|show_user}}
          </div>
          <div><b>Modified:</b><br/>
            {{issue.modified|timesince}} ago
          </div>
          <div><b>Reviewers:</b><br/>
            {{issue.formatted_reviewers|show_reviewers:issue.required_reviewers}}
          </div>
          {%if issue.cc%}
          <div><b>CC:</b><br/>
            {%nicknames issue.cc%}
          </div>
          {%endif%}
          {%if issue.base%}
          <div><b>Base URL:</b><br/>
            {%if src_url%}
              <a href="{{src_url}}" target="blank">
            {%endif%}
            {{issue.base}}
            {%if src_url%}
              </a>
            {%endif%}
          </div>
          {%endif%}
          {%if issue.target_ref%}
          <div><b>Target Ref:</b><br/>
            {{issue.target_ref}}
          </div>
          {%endif%}
          {%if issue.project%}
          <div><b>Project:</b><br/>
            <a href="{%url codereview.views.search%}?project={{issue.project}}">
              {{issue.project}}
            </a>
          </div>
          {%endif%}
          <div><b>Visibility:</b><br/>
            {%if issue.private%}
                Private/Protected. Only viewable by @chromium and @google accounts.
            {% else %}
                Public.
            {%endif%}
          </div>
          {%if issue.repo_guid%}
          <div><a title="Find reviews for the same repository ID - {{issue.repo_guid}}"
               href="{%url codereview.views.search%}?repo_guid={{issue.repo_guid}}">
            <b>More Reviews</b></a>
          </div>
          {%endif%}
        </div>
      </td>

      <td style="padding-left: .8em; padding-right: .8em;" width="80%">
        {%block issue_body%}BODY GOES HERE{%endblock%}
      </td>
    </tr>
  </table>
{%endblock%}


{%block popup%}
  {%if issue%}
    <div class="popup" id="popup-issue">
      <b>Issue {{issue.key.id}}: {{issue.subject}}
    {%if issue.closed %} (Closed) {%endif%}</b><br/>
      Created {{issue.created|timesince}} ago by {%nickname issue.owner%}<br/>
      Modified {{issue.modified|timesince}} ago<br/>
      Reviewers: {%nicknames issue.reviewers%}<br/>
      Base URL: {{issue.base}}<br/>
      Comments: {{issue.num_comments}}
      {%if issue|num_drafts:user%} <span style="color: red;">+
   {{issue|num_drafts:user}} drafts</span>{%endif%}
    </div>
  {%endif%}
{%endblock%}
